/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

void
PilhaWindow::init()
{
	this->pilhosa = new pilha<QString>;
}

void
PilhaWindow::destroy()
{
	delete this->pilhosa;
}



void PilhaWindow::pop()
{
	this->pilhosa->pop();
	
	this->updateData();
}


void PilhaWindow::enablePush()
{
	QString
	vazia = "";
	
	if (this->EditPush->text() != vazia )
	{
		this->BtnPush->setEnabled(true);
	}
	else
	{
		this->BtnPush->setEnabled(false);
	}
}


void PilhaWindow::push()
{
	this->pilhosa->push( this->EditPush->text() );
	
	this->EditPush->setText("");
	
	this->updateData();
}


void PilhaWindow::updateData()
{
	if (! this->pilhosa->isEmpty())
	{
		this->LabelShowTop->setText( this->pilhosa->getInfo() );
		
		this->BtnPop->setEnabled(true);
	}
	else
	{
		this->LabelShowTop->setText("Pilha Vazia!");
		
		this->BtnPop->setEnabled(false);
	}
}
